package com.du.lin.dao;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.du.lin.bean.SalesManagement;
import org.apache.ibatis.annotations.*;
import org.junit.runners.Parameterized;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;
import java.util.Map;

public interface SalesManagementMapper extends BaseMapper<SalesManagement> {

    @Select(" select sm.*,u.username as user_name from sales_management as sm  LEFT JOIN `user` u on u.id=sm.user_id where u.deptid=#{dept} and sm.create_date like  CONCAT(#{starttime},'%') ORDER BY sm.create_date asc")
    List<SalesManagement> getAllSalesManagements(@Param("dept") String dept, @Param("starttime") String starttime);

    @Select(" select sm.*,u.username as user_name from sales_management as sm  LEFT JOIN `user` u on u.id=sm.user_id where u.id=#{userId} and sm.create_date like  CONCAT(#{starttime},'%') ORDER BY sm.create_date asc")
    SalesManagement getSalesManagements(@Param("userId") String userId, @Param("starttime") String starttime);

    //插入
    @Insert(" insert into sales_management (user_id,create_date,number) value (#{userId},#{createDate},#{number})")
    int insertSalesManagementsByNumber(@Param("userId") String userId, @Param("createDate") String createDate,@Param("number") String number);

    @Insert(" insert into sales_management (user_id,create_date,wx_number) value (#{userId},#{createDate},#{wxNumber})")
    int insertSalesManagementsByWxNumber(@Param("userId") String userId, @Param("createDate") String createDate,@Param("wxNumber") String wxNumber);

    @Insert(" insert into sales_management (user_id,create_date,old_customers_number) value (#{userId},#{createDate},#{oldCustomersNumber})")
    int insertSalesManagementsByOldCustomersNumber(@Param("userId") String userId, @Param("createDate") String createDate,@Param("oldCustomersNumber") String oldCustomersNumber);

    @Insert(" insert into sales_management (user_id,create_date,new_customers_number) value (#{userId},#{createDate},#{newCustomersNumber})")
    int insertSalesManagementsByNewCustomersNumber(@Param("userId") String userId, @Param("createDate") String createDate,@Param("newCustomersNumber") String newCustomersNumber);

    @Insert(" insert into sales_management (user_id,create_date,old_apply_number) value (#{userId},#{createDate},#{oldApplyNumber})")
    int insertSalesManagementsByOldApplyNumber(@Param("userId") String userId, @Param("createDate") String createDate,@Param("oldApplyNumber") String oldApplyNumber);

    @Insert(" insert into sales_management (user_id,create_date,new_apply_number) value (#{userId},#{createDate},#{newApplyNumber})")
    int insertSalesManagementsByNewApplyNumber(@Param("userId") String userId, @Param("createDate") String createDate,@Param("newApplyNumber") String newApplyNumber);

    @Insert(" insert into sales_management (user_id,create_date,old_paragraph_number) value (#{userId},#{createDate},#{oldParagraphNumber})")
    int insertSalesManagementsByOldParagraphNumber(@Param("userId") String userId, @Param("createDate") String createDate,@Param("oldParagraphNumber") String oldParagraphNumber);

    @Insert(" insert into sales_management (user_id,create_date,new_paragraph_number) value (#{userId},#{createDate},#{newParagraphNumber})")
    int insertSalesManagementsByNewParagraphNumber(@Param("userId") String userId, @Param("createDate") String createDate,@Param("number") String newParagraphNumber);

    //更新
    @Update(" update sales_management set number=#{number} where id=#{id}")
    int updateSalesManagementsByNumber(@Param("id") String id,@Param("number") String number);

    @Update(" update sales_management set wx_number=#{wxNumber} where id=#{id}")
    int updateSalesManagementsByWxNumberr(@Param("id") String id,@Param("wxNumber") String wxNumber);

    @Update(" update sales_management set old_customers_number=#{oldCustomersNumber} where id=#{id}")
    int updateSalesManagementsByoldCustomersNumber(@Param("id") String id,@Param("oldCustomersNumber") String oldCustomersNumber);

    @Update(" update sales_management set new_customers_number=#{newCustomersNumber} where id=#{id}")
    int updateSalesManagementsBynewCustomersNumber(@Param("id") String id,@Param("newCustomersNumber") String newCustomersNumber);

    @Update(" update sales_management set old_apply_number=#{oldApplyNumber} where id=#{id}")
    int updateSalesManagementsByoldApplyNumber(@Param("id") String id,@Param("oldApplyNumber") String oldApplyNumber);

    @Update(" update sales_management set new_apply_number=#{newApplyNumber} where id=#{id}")
    int updateSalesManagementsBynewApplyNumber(@Param("id") String id,@Param("newApplyNumber") String newApplyNumber);

    @Update(" update sales_management set old_paragraph_number=#{oldParagraphNumber} where id=#{id}")
    int updateSalesManagementsByoldParagraphNumberr(@Param("id") String id,@Param("oldParagraphNumber") String oldParagraphNumber);

    @Update(" update sales_management set new_paragraph_number=#{newParagraphNumber} where id=#{id}")
    int updateSalesManagementsBynewParagraphNumber(@Param("id") String id,@Param("newParagraphNumber") String newParagraphNumber);

    //删除
    @Delete(" delete from sales_management where user_id=#{userId} and create_date like  CONCAT(#{date},'%')  ")
    int deletesales(@Param("userId") String userId,@Param("date") String date);
}